import { createRouter, createWebHashHistory } from "vue-router";

// const Home = () =>import("@/view/Home.vue")


//1.layout引入
import Layout from '@/layout/index.vue'
//2.导入页面
const Login = ()=> import("@/view/login/index.vue")
const PersonalIndex = ()=> import("@/view/personal/index.vue")
const PersonalMessage = ()=> import("@/view/personal/Message.vue")
const AppIndex = ()=> import("@/view/app/index.vue")

const NotFound = ()=> import("@/view/404.vue")
//3.路由的配置
const routes = [
    // {
    //     path:'/',
    //     component:Home
    // }

    {
        path: '/',
        name: 'Home',
        component: Layout,
        children: [
            {
                path: 'login',
                name: 'Login',
                component: Login,
            },
            {
                path: 'personal',
                name: 'Personal',
                component: PersonalIndex,
                children: [
                    {
                        path: 'message',
                        name: 'PersonalMessage',
                        component: PersonalMessage,
                    },
                ]
            },
            {
                path: 'app',
                name: 'App',
                component: AppIndex,
            },
            {
                path: '404',
                name: 'NotFound',
                component: NotFound,
            },
        ]
        
    },
    {
        path: '/:pathMatch(.*)*',
        name: '404',
        redirect: '/404',
    },
]

const router = createRouter({
    history:createWebHashHistory(),
    routes
})

export default router